home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Softshoe / Lisa's Mac Parts / Macintosh Memory / ApplicationZoneUser.cp next >
Text File  |  2000-06-23  |  980b  |  49 lines

  1. // ApplicationZoneUser.cp
  2.  
  3. #ifndef ApplicationZoneUser_h
  4. #include "ApplicationZoneUser.h"
  5. #endif
  6. #ifndef HeapZone_h
  7. #include "HeapZone.h"
  8. #endif
  9. #ifndef Assert_h
  10. #include "Assert.h"
  11. #endif
  12.  
  13. ApplicationZoneUser::ApplicationZoneUser( uint32 moreMasters,
  14.                                                         uint32 extraStackSpace )
  15.   {
  16.     static bool initialized = false;
  17.     static const uint32 mastersAdded( moreMasters );
  18.     static const uint32 stackSpaceAdded( extraStackSpace );
  19.     
  20.     if ( initialized )
  21.       {
  22.         Assert( moreMasters <= mastersAdded );
  23.         Assert( extraStackSpace <= stackSpaceAdded );
  24.         return;
  25.       }
  26.     
  27.     initialized = true;
  28.     
  29.     if ( extraStackSpace > 0 )
  30.         SetApplLimit( GetApplLimit() - extraStackSpace );
  31.     
  32.     if ( moreMasters > 0 )
  33.       {
  34.         Assert( moreMasters <= maxint16 );
  35.         
  36.         HeapZone& heap( HeapZone::Application() );
  37.         
  38.         uint16 oldIncrement = heap.moreMast;
  39.         if ( moreMasters > oldIncrement )
  40.             heap.moreMast = moreMasters;
  41.         
  42.         MoreMasters();
  43.         
  44.         heap.moreMast = oldIncrement;
  45.       }
  46.     
  47.     MaxApplZone();
  48.   }
  49.